//
//  HCGrouthLinesView.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/2/6.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCGrouthLinesView.h"

@interface  HCGrouthLinesView() <UITextViewDelegate> {
    UITextView *topTextView;
    UILabel *placeHolderLabel_;
}

@end

@implementation HCGrouthLinesView

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initializeSubView:frame];
    }
    return self;
}

-(void)initializeSubView:(CGRect)frame {
    topTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, frame.size.width - 20, frame.size.height - 20)];
    topTextView.delegate = self;
    topTextView.backgroundColor = [UIColor clearColor];
    topTextView.textColor = [UIColor darkGrayColor];
    [self addSubview:topTextView];
    
    placeHolderLabel_ = [[UILabel alloc] initWithFrame:CGRectMake(13, 14, frame.size.width - 20, 20)];
    placeHolderLabel_.textColor = [UIColor lightGrayColor];
    placeHolderLabel_.text = @"这一刻的想法...";
    placeHolderLabel_.font = [UIFont systemFontOfSize:13];
    [self addSubview:placeHolderLabel_];
}

-(void)textViewDidChange:(UITextView *)textView {
    if (textView.text.length == 0) {
        placeHolderLabel_.text = @"这一刻的想法...";
    }else{
        placeHolderLabel_.text = @"";
    }
    
    if (self.delegate) {
        [self.delegate hcGrouthAlbum:textView.text];
    }
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
